package mysql

import (
	"fmt"
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/mysql"
)

var (
	DB  *gorm.DB
	err error
)

func Init() {
	DB, err = gorm.Open("mysql", "root:root@(127.0.0.1:3306)/2208a?charset=utf8mb4&parseTime=True&loc=Local")
	if err != nil {
		panic(err)
	}
	fmt.Println("数据库连接成功")
	err = DB.AutoMigrate(&House{}).Error
	if err != nil {
		panic(err)
	}
}
